<?php
	if(!defined("IN_APP"))
	{
		exit;
	}
	
	if(!adminpermission('N','110000'))
	{
		echo '无权查看!';
		exit;
	}
	
	$method = getParam('m','get','list');
	
	$parm = requestArrayParm($_REQUEST);
	
	
	if($method == 'editGG')
	{
		$pagetitle = '修改公告信息';
		
		if($parm['id'])
		{
			unset($where,$data);
			$where['id'] = $parm['id'];
			$gonggao = _Gonggao::getGonggaoInfo($where);
			if($gonggao)
			{
				$gonggao['start'] = date('Y-m-d',$gonggao['fbtime']);
			}
			else
			{
				header("Location:".SITE_URL.'admin.php?a=gonggaoM');
			}
		}
		else
		{
			header("Location:".SITE_URL.'admin.php?a=gonggaoM');
		}
		
		include renderTemplate('gonggao/info');
	}
	
	if($method == 'addGG')
	{
		$pagetitle = '创建公告信息';
		
		include renderTemplate('gonggao/info');
	}
	
	if($method == 'list')
	{
		$typearr['name'] = '姓名';
		$typearr['phone'] = '手机号';
		
		$fTitle = "公告管理";
		$sTitle = "公告列表";
		
		$search = array();
		
		if($parm['start'] && $parm['end'])
		{
			$between['start'] = strtotime($parm['start']);
			
			$between['end'] = strtotime($parm['end'])+86399;
		}
		
		if($parm['status'])
		{
			$search['status'] = $parm['status'];
		}
		
		if($parm['keyword'])
		{
			$search['phone'] = $parm['keyword'];
		}
		
		$page = $pages['page'] = getParam('page','request','1');
		
		$pages['rows'] = 20;
		
		$resData = _Gonggao::getGonggaoListByOplog($search, $pages,array() ,$between);
		
		//查询对应的数据
		
		foreach ($resData['list']  as $key => $value)
		{
			$value['opinfo'] = _OpLog::getLastOpLog(array('table'=>'gonggao','union_id'=>$value['id']));
			$list[] = $value;
		}
		
		$pageurl = SITE_URL.'admin.php?'.set_URL_Param(get_URL_Param());
	
		$pagetotal = $resData["pages"];
		
		include renderTemplate('gonggao/list');
	}